#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    int ret = 0;
    int singleNumber(vector<int>& nums) {
        for (int i = 0; i <= 31; i++)
        {
            int sum = 0;
            for (auto j : nums)
                if ((j >> i) & 1) sum++;
            sum %= 3;
            if (sum) ret |= 1 << i;
        }
        return ret;
    }
};